import 'package:flutter_menu/biz/order/record/shop_car_controller.dart';
import 'package:json_annotation/json_annotation.dart';

part 'order_model.g.dart';

/// 下单接口返回数据
@JsonSerializable()
class OrderResp {
  String? orderUuid;

  OrderResp();

  factory OrderResp.fromJson(Map<String, dynamic> json) => _$OrderRespFromJson(json);
  Map<String, dynamic> toJson() => _$OrderRespToJson(this);
}

///电子菜单下单请求参数
@JsonSerializable()
class OrderRq {
  ///deviceId
  String? deviceId;

  ///商品列表
  List<OrderProductRV>? productList;

  ///备注
  String? remark;

  ///桌台uuid
  String? tableUuid;

  OrderRq({
    this.deviceId,
    this.productList,
    this.remark,
    this.tableUuid,
  });

  factory OrderRq.fromJson(Map<String, dynamic> json) => _$OrderRqFromJson(json);
  Map<String, dynamic> toJson() => _$OrderRqToJson(this);
}

///套餐请求
@JsonSerializable()
class BundleGroupRV {
  int? count;
  String? id;
  int? max;
  String? name;
  List<OrderProductRV>? productList;
  int? type;

  BundleGroupRV({
    this.count,
    this.id,
    this.max,
    this.name,
    this.productList,
    this.type,
  });
  factory BundleGroupRV.fromJson(Map<String, dynamic> json) => _$BundleGroupRVFromJson(json);
  Map<String, dynamic> toJson() => _$BundleGroupRVToJson(this);
}

///在线产品信息
@JsonSerializable()
class OrderProductRV {
  String? allFood;
  double? allPrice;

  ///套餐选项组
  List<BundleGroupRV>? bundleGroup;

  ///套餐Id
  int? bundleProductId;
  double? calcuPrice;

  ///菜品分类id
  String? categoryId;

  ///菜品分类名
  String? categoryName;

  ///计数
  double? count;

  ///菜品id
  String? id;

  ///是否套餐
  int? isBundle;

  ///是否折扣
  int? isDiscount;
  int? isDiscountEnable;

  ///菜品名
  String? name;
  double? originalPrice;

  ///价格
  double? price;
  int? productType;

  ///可点数量
  int? remainingAmount;

  ///菜品备注
  String? remark;

  ///第二语言名
  String? secondName;

  ///规格列表
  List<DishRV>? specs;

  ///税费
  double? taxPrice;
  int? useRemaining;

  OrderProductRV({
    this.allFood,
    this.allPrice,
    this.bundleGroup,
    this.bundleProductId,
    this.calcuPrice,
    this.categoryId,
    this.categoryName,
    this.count,
    this.id,
    this.isBundle,
    this.isDiscount,
    this.isDiscountEnable,
    this.name,
    this.originalPrice,
    this.price,
    this.productType,
    this.remainingAmount,
    this.remark,
    this.secondName,
    this.specs,
    this.taxPrice,
    this.useRemaining,
  });

  factory OrderProductRV.fromJson(Map<String,dynamic> json) => _$OrderProductRVFromJson(json);
  Map<String, dynamic> toJson() => _$OrderProductRVToJson(this);

}

///规格列表
@JsonSerializable()
class DishRV {
  double? allPrice;
  double? calcuPrice;
  double? costPrice;
  double? count;
  String? id;
  int? isDefault;
  int? isDiscountEnable;
  String? name;
  List<SpecGroupRV>? optionGroup;
  double? price;
  int? remainingAmount;
  double? reserveMin;
  String? secondName;
  double? taxPrice;
  int? useRemaining;

  DishRV({
    this.allPrice,
    this.calcuPrice,
    this.costPrice,
    this.count,
    this.id,
    this.isDefault,
    this.isDiscountEnable,
    this.name,
    this.optionGroup,
    this.price,
    this.remainingAmount,
    this.reserveMin,
    this.secondName,
    this.taxPrice,
    this.useRemaining,
  });

  factory DishRV.fromJson(Map<String, dynamic> json) => _$DishRVFromJson(json);
  Map<String, dynamic> toJson() => _$DishRVToJson(this);
}

@JsonSerializable()
class SpecGroupRV {
  List<SpecOptionRV>? options;
  int? optionsGroupId;
  String? optionsGroupName;
  String? optionsGroupSecondName;
  int? type;

  SpecGroupRV({
    this.options,
    this.optionsGroupId,
    this.optionsGroupName,
    this.optionsGroupSecondName,
    this.type,
  });

  factory SpecGroupRV.fromJson(Map<String, dynamic> json) => _$SpecGroupRVFromJson(json);
  Map<String, dynamic> toJson() => _$SpecGroupRVToJson(this);
}

@JsonSerializable()
class SpecOptionRV {
  int? count;
  String? id;
  int? isDefault;
  String? name;
  double? price;
  String? secondName;
  bool? selected;
  double? taxPrice;
  int? type;

  SpecOptionRV({
    this.count,
    this.id,
    this.isDefault,
    this.name,
    this.price,
    this.secondName,
    this.selected,
    this.taxPrice,
    this.type,
  });
  factory SpecOptionRV.fromJson(Map<String, dynamic> json) => _$SpecOptionRVFromJson(json);
  Map<String, dynamic> toJson() => _$SpecOptionRVToJson(this);
}

///列表出参对象«线上/电子菜单订单详情»
@JsonSerializable()
class OrderRecordListResp {
  ///列表数据
  List<OrderRecordResp>? rows;

  ///总数
  int? total;

  OrderRecordListResp({
    this.rows,
    this.total,
  });

  factory OrderRecordListResp.fromJson(Map<String, dynamic> json) =>
      _$OrderRecordListRespFromJson(json);
  Map<String, dynamic> toJson() => _$OrderRecordListRespToJson(this);
}

///线上/电子菜单订单详情
@JsonSerializable()
class OrderRecordResp {
  ///创建时间
  String? createTime;

  ///外卖配送费
  double? deliveryFee;

  ///是否结算(0:未结算 1:已结算)
  int? isSettlement;

  ///就餐人数
  int? numOfPeople;

  ///订单类型 1:扫码点餐 2 扫码外卖  3 到店取餐 4 电子菜单点单
  int? onlineOrderType;

  ///线上支付渠道 1 shopeeyPay 2 etPay
  int? onlinePayChanel;

  ///订单id
  String? orderId;

  ///小费
  List<OrderTipResp>? orderTips;

  ///有效期截至时间时间戳
  int? overTime;

  ///支付关联id
  String? paymentReferenceId;

  ///付款时间
  String? paymentTime;

  ///取餐号
  String? pickUpNo;

  ///取货时间
  String? pickUpTime;

  ///订单菜品json数据
  OrderProductRV? productData;

  ///二维码
  String? qrUrl;

  ///服务费
  List<ServiceChargeResp>? serviceChargeResults;

  ///结算价格
  double? settlementSum;

  ///状态（0待确认 1已确认 2已拒绝  3待支付 4已取消）
  String? status;

  ///税费
  List<TaxResp>? taxes;

  ///所有菜品的合计
  double? totalSum;

  ///最后更新时间
  String? updateTime;

  ///有效时间（s）
  int? validTime;

  OrderRecordResp(
      {this.createTime,
      this.deliveryFee,
      this.isSettlement,
      this.numOfPeople,
      this.onlineOrderType,
      this.onlinePayChanel,
      this.orderId,
      this.orderTips,
      this.overTime,
      this.paymentReferenceId,
      this.paymentTime,
      this.pickUpNo,
      this.pickUpTime,
      this.productData,
      this.qrUrl,
      this.serviceChargeResults,
      this.settlementSum,
      this.status,
      this.taxes,
      this.totalSum,
      this.updateTime,
      this.validTime});

  factory OrderRecordResp.fromJson(Map<String, dynamic> json) => _$OrderRecordRespFromJson(json);
  Map<String, dynamic> toJson() => _$OrderRecordRespToJson(this);
}

///订单小费
@JsonSerializable()
class OrderTipResp {
  ///创建时间
  int? createTime;

  ///分润比例
  double? distributionRate;

  ///是否启用绩效员工
  bool? enableUserJobs;

  ///小费id
  String? id;

  ///登陆员工id
  String? loginUserId;

  ///订单小费id
  String? orderTipId;

  ///订单消费类型: 0 店铺小费 1 补录小费
  int? orderTipType;

  ///小费收取金额
  double? tipAmount;

  ///小费类型 1 百分比 2 固定金额
  int? tipType;

  ///小费比例|金额
  double? tipValue;

  ///类型 0 店铺小费 1 自定义小费
  int? type;

  ///分成小费员工id
  String? userId;

  OrderTipResp({
    this.createTime,
    this.distributionRate,
    this.enableUserJobs,
    this.id,
    this.loginUserId,
    this.orderTipId,
    this.orderTipType,
    this.tipAmount,
    this.tipType,
    this.tipValue,
    this.type,
    this.userId,
  });

  factory OrderTipResp.fromJson(Map<String, dynamic> json) => _$OrderTipRespFromJson(json);
  Map<String, dynamic> toJson() => _$OrderTipRespToJson(this);
}

///订单服务费
@JsonSerializable()
class ServiceChargeResp {
  ///合计金额
  double? amount;

  ///订单服务费id
  String? id;

  ///参与的菜品列表
  List<String>? productList;

  ///服务费id
  String? serviceChargeId;

  ///服务费名称
  String? serviceChargeName;

  ///服务费金额
  double? serviceChargeValue;

  ServiceChargeResp({
    this.amount,
    this.id,
    this.productList,
    this.serviceChargeId,
    this.serviceChargeName,
    this.serviceChargeValue,
  });

  factory ServiceChargeResp.fromJson(Map<String, dynamic> json) =>
      _$ServiceChargeRespFromJson(json);
  Map<String, dynamic> toJson() => _$ServiceChargeRespToJson(this);
}

///订单税费
@JsonSerializable()
class TaxResp {
  ///带小数的费率
  double? doubleValue;

  ///税费ID
  String? id;

  ///是否生效 0.不生效 1.生效
  int? isEnable;

  ///税费名称
  String? name;

  ///商品税费总计
  double? normalTaxSum;

  ///菜品list
  List<String>? productList;

  ///服务费税费总计
  double? serviceTaxSum;

  ///状态（0正常 1停用）
  int? status;

  ///税费合计, = 商品税费总计 + 服务费税费总计
  double? sum;

  ///税率类型：默认0：IVA，1：IEPS
  String? taxesType;

  ///使用范围  0 全部菜品 1:自定义菜品
  int? useType;

  ///税费值
  double? value;

  TaxResp({
    this.doubleValue,
    this.id,
    this.isEnable,
    this.name,
    this.normalTaxSum,
    this.productList,
    this.serviceTaxSum,
    this.status,
    this.sum,
    this.taxesType,
    this.useType,
    this.value,
  });
  factory TaxResp.fromJson(Map<String, dynamic> json) => _$TaxRespFromJson(json);
  Map<String, dynamic> toJson() => _$TaxRespToJson(this);
}
